package com.example.flow.dao.impl;

import com.example.flow.dao.FlowOrderHisDao;
import com.example.flow.dao.mapper.FlowOrderHisMapper;
import com.example.flow.dao.model.FlowOrderHis;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author tangaq
 * 2023/6/15
 */
@Service
public class RdsFlowOrderHisDaoImpl implements FlowOrderHisDao {
    private final FlowOrderHisMapper orderHisMapper;

    public RdsFlowOrderHisDaoImpl(FlowOrderHisMapper orderHisMapper) {
        this.orderHisMapper = orderHisMapper;
    }

    @Override
    public FlowOrderHis findByOrderId(String orderId) {
        FlowOrderHis query = new FlowOrderHis();
        query.setOrderId(orderId);
        return orderHisMapper.selectOne(query);
    }

    @Override
    public void deleteByOrderId(String orderId) {
        if (StringUtils.isBlank(orderId)) {
            return;
        }
        FlowOrderHis query = new FlowOrderHis();
        query.setOrderId(orderId);
        orderHisMapper.delete(query);
    }

    @Override
    public void insert(FlowOrderHis history) {
        orderHisMapper.insert(history);
    }
}
